<%-- 
    Document   : addProductToACaddy
    Created on : 31 mai 2012, 00:21:39
    Author     : isen
--%>

<%@page import="persistence.PersistenceImplementation"%>
<%@page import="persistence.PersistenceInterface"%>
<%@page import="model.Product"%>
<%@page import="java.util.HashMap"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Add products to a caddy</title>
    </head>
    <body>
        <%if (request.getAttribute("resultado") != null) {%>
        <p><%= request.getAttribute("resultado")%></p>
        <% }%>    


        <% HashMap<String, Product> productos = PersistenceImplementation.getJDBCPersistenceManager().getProducts();
            if (productos != null) {
        %>

    <center>
                <h1>Products you can choose:</h1>
        <form action="/MyFrontController"><input type="hidden" name="form" value="addtomycart" />

            <table>

                <tr><td>Nombre</td><td>Precio</td></tr>
                <% for (Product prod : productos.values()) {%>

                <tr>
                    <td><%= prod.getNombre()%><input type="hidden" name="productname" value="<%= prod.getNombre()%>" /> </td>

                    <td><%= prod.getPrecio()%></td>

                    <td>quantity you want to buy: <input type="text" name="quantity" value="0" size="3"/> </td>

                </tr>

                <% }%>
            </table>

            <% } else {%>
            <p>No se han encontrado productos, disculpe las molestias</p>
            <% }%>

            <input type="submit" value="Add to my cart" name="addproductstothecart" />

        </form>

    </center>           
 <%@include file="/WEB-INF/include/menuClient.jsp" %>            
            
    </body>
</html>
